﻿using Box2DSharp.Collision.Shapes;
using OpenTK.Mathematics;

namespace TrinityEngine
{
    public class BoxCollider2D : Collider2D
    {
        private PolygonShape _shape;

        public Vector2 offset
        {
            get { return _offset; }
            set
            {
                _offset = value;
                _shape.SetAsBox(_size.x / 2f, _size.y / 2f, _offset, 0f);
            }
        }
        private Vector2 _offset;

        public Vector2 size
        {
            get { return _size; }
            set
            {
                _size = value;
                _shape.SetAsBox(_size.x / 2f, _size.y / 2f, _offset, 0f);
            }
        }
        private Vector2 _size;

        public BoxCollider2D(Vector2 size)
        {
            _shape = new PolygonShape();
            _offset = Vector2.zero;
            this.size = size;
        }

        public override Shape GetShape()
        {
            return _shape;
        }
    }
}
